const winston = require('winston')
const logger = winston.createLogger({
  level: 'info',
  format: winston.format.combine(
    winston.format.timestamp(),
    winston.format.errors({ stack: true }),
    winston.format.prettyPrint(),
  ),
  defaultMeta: { service: 'english-all-in-one' },
  transports: [
    new winston.transports.File({ filename: 'logs/error.log', level: 'error',maxsize: 5242880 }),
    new winston.transports.File({ filename: 'logs/combined.log',maxsize: 5242880 })
  ],
})

if (process.env.NODE_ENV !== 'production') {
  logger.add(new winston.transports.Console({
    format: winston.format.simple()
  }))
}

module.exports = logger